// run: $exec < input
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <functional>

struct node { int to, cost; };

int const inf = 1 << 29;
int const maxn = 3000;

std::vector<node> graph[maxn];
typedef std::vector<node>::iterator edge_iter;

int n, m, k, ds;

int p = -1;
double max = 0, avg = -1;

void add_edge(int x, int y, int z)
{
	graph[x].push_back({y, z});
}

void dijkstra(int source)
{
	int num = n + m + 4;
	int dist[num];
	std::fill(dist, dist + num, inf);
	dist[source] = 0;
	typedef std::pair<int, int> cost_end;
	std::priority_queue<cost_end, std::vector<cost_end>, std::greater<cost_end> > pq;
	pq.push(std::make_pair(0, source));
	while (!pq.empty()) {
		cost_end tmp = pq.top(); pq.pop();
		int u = tmp.second;
		if (dist[u] < tmp.first) continue;

		for (edge_iter edge = graph[u].begin(); edge != graph[u].end(); ++edge) {
			int v = edge->to, c = edge->cost;
			if (dist[v] > dist[u] + c) {
				dist[v] = dist[u] + c;
				pq.push(std::make_pair(dist[v], v));
			}
		}
	}
	double tmin = inf, sum = 0;
	for (int i = 1; i <= n; i++) {
		if (dist[i] > ds) return;
		tmin = std::min(tmin, double(dist[i]));
		sum += dist[i];
	}
	if (tmin > max) {
		max = tmin;
		avg = sum;
		p = source - n;
	} else if (tmin == max) {
		if (sum < avg) {
			p = source - n;
			avg = sum;
		}
	}
}

int get(std::string const & s)
{
	if (s[0] != 'G') return std::stoi(s);
	return n + stoi(std::string(s.begin() + 1, s.end()));
}

int main()
{
	std::ios::sync_with_stdio(false);
	std::cin >> n >> m >> k >> ds;
	for (int i = 0, x, y, c; i < k; i++) {
		std::string t;
		std::cin >> t; x = get(t);
		std::cin >> t; y = get(t);
		std::cin >> c;
		add_edge(x, y, c);
		add_edge(y, x, c);
	}
	for (int i = 1; i <= m; i++)
		dijkstra(n + i);
	if (p < 0)
		std::cout << "No Solution\n";
	else {
		std::cout << "G" << p << '\n';
		double ans = avg * 10.0 / n;
		ans = round(ans);
		ans /= 10.0;
		std::cout << std::fixed << std::setprecision(1) << max << ' ' << ans << '\n';
	}
}

